﻿
#region Usings

using PolyGameEngine.GamePieces;



using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;

#endregion
public enum GameState
    {
       Menu, Help, Pause,Play, Close, LevelSelect, About, Edit
    }
namespace PolyGameEngine.Tools
{
    public class PhysicsGame : Microsoft.Xna.Framework.Game
    {
        public GraphicsDeviceManager graphics;
        public SpriteBatch spriteBatch;
        public AssetCreator assetcreator;
        public SpriteFont[] Fonts = new SpriteFont[1];
        public static GameState gamestate = GameState.Menu;
        public static GameState PreviousGameState;
        public static void ChangeGameState(GameState Gamestate)
        {
            PreviousGameState = gamestate;
            gamestate = Gamestate;
        }
        
        public PhysicsGame()
        {
            graphics = new GraphicsDeviceManager(this);
            Content.RootDirectory = "Content";
          //  graphics.IsFullScreen = true;
            graphics.PreferredBackBufferWidth = GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Width;
            graphics.PreferredBackBufferHeight = GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Height;

        }

        protected override void Initialize()
        {
            base.Initialize();
        }
        protected override void LoadContent()
        {
            spriteBatch = new SpriteBatch(GraphicsDevice);
            assetcreator = new AssetCreator(graphics.GraphicsDevice);
            base.LoadContent();
        }


        protected override void Update(GameTime gameTime)
        {
            InputMan.Update();
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape))
            {
                AudioMan.PlayCue("Trampoline");
                ChangeGameState(GameState.Pause);
            }


            if (gamestate == GameState.Edit)
                if (InputMan.OnPress(Keys.Tab))
                    viewDebug = !viewDebug;
            base.Update(gameTime);

        }

        

        public bool viewDebug = false;
        public Texture2D Background;
        protected override void Draw(GameTime gameTime)
        {
            if (GamePiece._ScreenOffset.X >= 0 )
                GamePiece._ScreenOffset = new Vector2(0, GamePiece._ScreenOffset.Y); 
            if (GamePiece._ScreenOffset.Y >= 0)
                GamePiece._ScreenOffset = new Vector2(GamePiece._ScreenOffset.X,0);
            base.Draw(gameTime);
        }

    }
}
